<template>
    <div class="article_info_con">
        <div class="left_content">
            <div v-highlight class="markdown-body markdown_content" v-html="markdownHTML"></div>
            <div class="aside_back iconfont" @click="back">&#xe953;</div>
            <div class="comment_con">
                <div class="line">
                    <span class="iconfont .icon-a-84-jiandao"></span>
                </div>
            </div>
        </div>
        <ScrollTop />
        <div class="right_content"></div>
    </div>
</template>
<script>
import { $getArticleByID } from "@/api/desk"
import { marked } from "marked"
import 'highlight.js/styles/atom-one-dark.css'
import 'github-markdown-css/github-markdown.css'
import ScrollTop from "@/components/ScrollTop.vue"
export default {
    data() {
        return {
            article_id: this.$route.query.id,
            markdownHTML: ""
        }
    },
    created() {
        this.getArticleById(this.article_id)
    },
    components:{ScrollTop},
    methods: {
        getArticleById(id) {
            $getArticleByID({
                id
            }).then(result => {
                console.log("文章内容:", result)
                this.markdownHTML = marked(result.data.content)
            })
        },

        // 返回
        back(){
            this.$router.go(-1)
        }
    }
}
</script>
<style lang="scss" scoped>
@media screen and (max-width:1200px) {
    .article_info_con {
        width: 100%;
        height: 100%;

        .left_content {
            margin: 0 !important;
        }

        .right_content {
            display: none;
        }
    }
}

.article_info_con {
    width: 100%;
    height: 100%;
    display: flex;

    .left_content::-webkit-scrollbar {
        background-color: rgb(242, 242, 242);
        width: 10px;
        border-radius: 10px;
    }

    .left_content::-webkit-scrollbar-thumb {
        background-color: #000000;
        border-radius: 5px;
    }

    .left_content {
        flex: 1 auto;
        height: 100%;
        margin: 0 10px 0 25px;
        padding: 20px;
        overflow-y: scroll;
        overflow-x: hidden;
        box-sizing: border-box;
        font-size: 15px;
        background-color: rgb(255, 255, 255);
        color: #444 !important;

        .comment_con{
            width: 100%;
            height: 50px;
        }

        .markdown_content {
            width: 100%;
            height: 100%;
            margin-bottom: 100px;

            ::v-deep {
                pre code.hljs {
                    display: block;
                    overflow-x: auto;
                }

                code.hljs {
                    padding: 0 5px
                }

                /*!
                Theme: GitHub Dark Dimmed
                Description: Dark dimmed theme as seen on github.com
                Author: github.com
                Maintainer: @Hirse
                Updated: 2021-05-15

                Colors taken from GitHub's CSS
                */
                .hljs {
                    color: #adbac7;
                    background: #22272e
                }

                .hljs-doctag,
                .hljs-keyword,
                .hljs-meta .hljs-keyword,
                .hljs-template-tag,
                .hljs-template-variable,
                .hljs-type,
                .hljs-variable.language_ {
                    color: #f47067
                }

                .hljs-title,
                .hljs-title.class_,
                .hljs-title.class_.inherited__,
                .hljs-title.function_ {
                    color: #dcbdfb
                }

                .hljs-attr,
                .hljs-attribute,
                .hljs-literal,
                .hljs-meta,
                .hljs-number,
                .hljs-operator,
                .hljs-selector-attr,
                .hljs-selector-class,
                .hljs-selector-id,
                .hljs-variable {
                    color: #6cb6ff
                }

                .hljs-meta .hljs-string,
                .hljs-regexp,
                .hljs-string {
                    color: #96d0ff
                }

                .hljs-built_in,
                .hljs-symbol {
                    color: #f69d50
                }

                .hljs-code,
                .hljs-comment,
                .hljs-formula {
                    color: #768390
                }

                .hljs-name,
                .hljs-quote,
                .hljs-selector-pseudo,
                .hljs-selector-tag {
                    color: #8ddb8c
                }

                .hljs-subst {
                    color: #adbac7
                }

                .hljs-section {
                    color: #316dca;
                    font-weight: 700
                }

                .hljs-bullet {
                    color: #eac55f
                }

                .hljs-emphasis {
                    color: #adbac7;
                    font-style: italic
                }

                .hljs-strong {
                    color: #adbac7;
                    font-weight: 700
                }

                .hljs-addition {
                    color: #b4f1b4;
                    background-color: #1b4721
                }

                .hljs-deletion {
                    color: #ffd8d3;
                    background-color: #78191b
                }
            }

            ::v-deep pre {
                display: flex;
                background-color: #22272e;

                .pre-numbering {
                    width: auto;
                    max-width: 30px;
                    flex: 0;

                    border-right: 1px solid #aaa;
                    padding-right: 4px;
                    color: #999;
                    text-align: right;
                }

                code {
                    flex: 1 auto;
                    padding: 0 0 0 4px;
                    box-sizing: border-box;
                    overflow-x: scroll;
                }
            }
        }
    }



    // 返回按钮
    .aside_back {
        position: absolute;
        width: 35px;
        height: 35px;
        line-height: 28px;
        text-align: center;
        border-radius: 50%;
        color: white;
        right: 0px;
        bottom: 0px;
        background-color: #00b2ff;
        font-size: 20px;
        box-shadow: 0 0 10px -5px #000;
        margin: 0 50px 50px 0;
        transition: 0.3s;
    }

    .aside_back:hover {
        transform: scale(1.02);
        cursor: pointer;
    }
}
</style>